class Student
{
    public:
      
      static float maxAve;
      string num;
      string name;
      int s1,s2;
      Student(string num, string name,int s1, int s2)
      {
          this->num = num;
          this->name = name;
          this->s1 = s1;
          this->s2 = s2;
          
      }
      virtual void display()
      {
          cout <<"base display"<< endl;
      }
     
};


float Student::maxAve  = 0;

class GroupA: public Student
{
    public:
      GroupA(string num, string name, int s1, int s2):Student(num,name,s1,s2)
      {
          float ave = (s1+s2)/2.0f;
        
          if(ave > maxAve)
              maxAve = ave;
          

      }
      virtual void display()
      {
         float ave = (s1 + s2)/2.0;
       
         if(ave >= maxAve)
           cout << num << " " << name << endl;
      }
};
class GroupB: public Student
{
    public:
     char gs;
      GroupB(string num, string name, int s1, int s2, char gs):Student(num,name,s1,s2)
      {
          this->gs = gs;
          float ave = (s1+s2)/2.0f;
         
          if(ave > maxAve)
              maxAve = ave;
         

      }
      virtual void display()
      {
      
         float ave = (s1 + s2)/2.0;
       
         if((ave >=(maxAve*0.7) && gs == 'A') || ave>=maxAve)
           cout << num << " " << name << endl;
         
      }
};
class GroupC: public Student
{
    public:
      int s3;
      int s4;
      int s5;
      GroupC(string num, string name, int s1, int s2,int s3, int s4,int s5):Student(num,name,s1,s2)
      {
           this->s3 = s3;
           this->s4 = s4;
           this->s5 = s5;
         
      }
      virtual void display()
      {
           float ave = (s1 + s2 +s3 + s4 + s5) / 5.0;
        
           if(ave >=(maxAve * 0.9))
             cout << num << " " << name << endl;
        
      }
};